import { lazy } from "react";
import {createBrowserRouter} from "react-router-dom"
import { BeforeEach } from "./BeforeEach";

const Home=lazy(()=> import("../pages/Home/Home"));
const Login=lazy(()=> import("../pages/Login/Login"));
const My=lazy(()=> import("../pages/My/My"));
const Xc=lazy(()=> import("../pages/Xc/Xc"));
const Kh=lazy(()=> import("../pages/Kh/Kh"));
const Tabbar=lazy(()=> import("../pages/Tabbar/Tabbar"));
const Chelist=lazy(()=> import("../pages/Chelist/Chelist"));
const List=lazy(()=> import("../pages/List/List"));

export const routes=([
    {
        path:"/",
        element:<Tabbar></Tabbar>,
        children:[
            {
                path:'/',
                element:<Home></Home>
            },
            {
                path:'/xc',
                element:<Xc></Xc>
            },
            {
                path:'/kh',
                element:<Kh></Kh>
            },
            {
                path:'/my',
                element:<My></My>
            },
        ]
    },
    {
        path:'/login',
        element:<Login></Login>
    },
    {
        path:'/chelist',
        element:<Chelist></Chelist>
    },
    {
        path:'/list',
        element:<List></List>
    },
])

export const priviteRoutes=createBrowserRouter(
    routes.map((v)=>{
        return {...v,element:<BeforeEach>{v.element}</BeforeEach>}
    })
)